<?php


namespace app\admin\business;


use app\common\model\Link;
use think\Exception;

class linkBus
{
    public $linkModel = null;
    public function __construct()
    {
        $this->linkModel = new Link();
    }
    public function addItemBus($data){
        $res = $this->linkModel->addItem($data);
        if (empty($res)){
            throw new Exception('添加失败请查看数据');
        }
        return $res;
    }
    public function getListPageBus($paging){
        $res = $this->linkModel->getAllList($paging);
        return $res;
    }
    public function getListPageBusByWhere($paging){
        $where = [
            'status' => 1
        ];
        $res = $this->linkModel->getListByWhere($where,$paging);
        return $res;
    }
    public function changeFieldByWhereBus($where,$data){
        $res = $this->linkModel->changeFieldByWhere($where,$data);
        if (empty($res)){
            throw new Exception('更新失败请查看数据');
        }
        return $res;
    }
    public function removeByWhereBus($where){
        $res = $this->linkModel->removeByWhere($where);
        if (empty($res)){
            throw new Exception('更新失败请查看数据');
        }
        return $res;
    }
    public function getDetailByWhereBus($where){
        $res = $this->linkModel->getDetailByWhere($where);
        if (empty($res)){
            throw new Exception('无法查看或者已删除');
        }
        return $res;
    }
    public function editItemBus($where,$date){
        $res = $this->linkModel->editItem($where,$date);
        if (empty($res)){
            throw new Exception('修改失败');
        }
        return $res;
    }
}